<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <h2>当前计数{{ count }}</h2>
        <!-- 监听事件，click事件 -->
        <button v-on:click="count++">+</button>
        <button @click="count--">-</button>
        
        <!-- 传入函数 -->
        <button v-on:click="add">+</button>
        <button @click="sub">-</button>
        <!-- @click是一种简写 -->

    </div>
    <script>
        const app = new Vue({
            el: "#app",
            data: {
                count: 0
            },
            // 定义方法
            methods: {
                add: function () {
                    this.count++;
                },
                sub: function () {
                   this.count--;
                }
            }
        })
    </script>
</body>
</html>